<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
        <script type="text/javascript">
            var storeId = GetURLParameter('storeId');
            if (typeof storeId === 'undefined') {
                storeId = "10152";
            }
            getPLaceholderName();
            
            function GetURLParameter(sParam) {
                var sPageURL = window.location.search.substring(1);
                var sURLVariables = sPageURL.split('&');
                for (var i = 0; i < sURLVariables.length; i++) {
                    var sParameterName = sURLVariables[i].split('=');
                    if (sParameterName[0] === sParam) {
                        return sParameterName[1];
                    }
                }
            }         

            function getPLaceholderName() {
                console.log("Start get placeholder name");                
                var xmlhttp = new XMLHttpRequest();
                var url = "nameFieldOrgId.json";
                xmlhttp.onreadystatechange = function () {
                    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) { 
                        var valuePlaceholder = JSON.parse(xmlhttp.responseText);
                        if(typeof valuePlaceholder[storeId] !== 'undefined'){
                            console.log(valuePlaceholder[storeId][1]);
                            $("#inputPlaceholder").attr("placeholder", valuePlaceholder[storeId][1]);
                        } else {
                            $("#inputPlaceholder").attr("placeholder", "ID organización");
                        }
                        console.log("Got place holder");                     
                    }
                };
                xmlhttp.open("GET", url, true);
                xmlhttp.send();
            }
        </script>
    </head>
    <body>
        <input type="text" id="inputPlaceholder" name="inputPlaceholder" />
    </body>
</html>
